package removeelement;

/**
 * @author XY
 * @version 1.0.0
 * @ClassName LC26.java
 * @createTime 2025年07月23日 19:59:00
 */
public class LC26 {
    public int removeDuplicates(int[] nums) {
        if (nums.length == 1) {
            return 1;
        }
        int slow = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != nums[slow]) {
                slow++;
                nums[slow] = nums[i];
            }
        }
        return slow + 1;
    }
}
